# Contributor: z3bra <willy at mailoo dot org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=libcaca
pkgver=0.99_beta20
_ver=${pkgver/_/.}
pkgrel=3
pkgdesc="graphics library that outputs text instead of pixels"
url="http://caca.zoy.org/wiki/libcaca"
arch="all"
license="WTFPL"
makedepends="imlib2-dev automake autoconf libtool"
subpackages="
	$pkgname-static
	$pkgname-dev
	$pkgname-doc
	$pkgname-apps
	py3-$pkgname-pyc:pyc
	py3-$pkgname:_py:noarch
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/cacalabs/libcaca/archive/refs/tags/v$_ver.tar.gz"
builddir="$srcdir"/libcaca-$_ver

# secfixes:
#   0.99_beta20-r0:
#     - CVE-2021-30498
#     - CVE-2021-30499
#     - CVE-2021-3410
#   0.99_beta19-r3:
#     - CVE-2018-20544
#     - CVE-2018-20545
#     - CVE-2018-20546
#     - CVE-2018-20547
#     - CVE-2018-20548
#     - CVE-2018-20549

prepare() {
	default_prepare
	sh bootstrap
	# We need to do this since the _beta20 suffix that is put
	# on version is invalid
	sed -e "s|@VERSION@|${pkgver%_*}|" \
		-i cxx/caca++.pc.in \
		-i caca/caca.pc.in
}

build() {
	./configure --prefix=/usr
	make
}

package() {
	make DESTDIR=$pkgdir install
	install COPYING -Dm644 $pkgdir/usr/share/licenses/$pkgname/LICENSE
}

apps() {
	mkdir -p "$subpkgdir"/usr/
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

_py() {
	pkgdesc="$pkgdesc (python bindings)"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/lib/python*
}

sha512sums="
012ab757bd996a7a0302d5b7d9a94c4e7db8532378096529b9617f815fdcd3dbea9c0e3fdfd14a1aeb8936f0b412e38a1bba8b846ab4bc61ca661df6a8d7a332  libcaca-0.99_beta20.tar.gz
"
